package com.shareloke.server.netty.model

import io.netty.buffer.ByteBufAllocator
import io.netty.channel.*
import io.netty.util.Attribute
import io.netty.util.AttributeKey
import java.net.SocketAddress

/**
 *
 *  描述：自定义channel
 *
 * @author wlp
 * @version 1.0.0
 * @date 2021/7/13 上午 09:31
 */
class WebsocketChannel(val userId: String, private val channel: Channel) : Channel {

    override fun id(): ChannelId {
        return channel.id()
    }

    override fun eventLoop(): EventLoop {
        return channel.eventLoop()
    }

    override fun parent(): Channel {
        return channel.parent()
    }

    override fun config(): ChannelConfig {
        return channel.config()
    }

    override fun isOpen(): Boolean {
        return channel.isOpen
    }

    override fun isRegistered(): Boolean {
        return channel.isRegistered
    }

    override fun isActive(): Boolean {
        return channel.isActive
    }

    override fun metadata(): ChannelMetadata? {
        return null
    }

    override fun localAddress(): SocketAddress {
        return channel.localAddress()
    }

    override fun remoteAddress(): SocketAddress {
        return channel.remoteAddress()
    }

    override fun closeFuture(): ChannelFuture {
        return channel.closeFuture()
    }

    override fun isWritable(): Boolean {
        return channel.isWritable
    }

    override fun bytesBeforeUnwritable(): Long {
        return channel.bytesBeforeUnwritable()
    }

    override fun bytesBeforeWritable(): Long {
        return channel.bytesBeforeWritable()
    }

    override fun unsafe(): Channel.Unsafe {
        return channel.unsafe()
    }

    override fun pipeline(): ChannelPipeline {
        return channel.pipeline()
    }

    override fun alloc(): ByteBufAllocator {
        return channel.alloc()
    }

    override fun bind(localAddress: SocketAddress): ChannelFuture {
        return channel.bind(localAddress)
    }

    override fun connect(remoteAddress: SocketAddress): ChannelFuture {
        return channel.connect(remoteAddress)
    }

    override fun connect(remoteAddress: SocketAddress, localAddress: SocketAddress): ChannelFuture {
        return channel.connect(remoteAddress, localAddress)
    }

    override fun disconnect(): ChannelFuture {
        return channel.disconnect()
    }

    override fun close(): ChannelFuture {
        return channel.close()
    }

    override fun deregister(): ChannelFuture {
        return channel.deregister()
    }

    override fun bind(localAddress: SocketAddress, promise: ChannelPromise): ChannelFuture {
        return channel.bind(localAddress, promise)
    }

    override fun connect(remoteAddress: SocketAddress, promise: ChannelPromise): ChannelFuture {
        return channel.connect(remoteAddress, promise)
    }

    override fun connect(
        remoteAddress: SocketAddress,
        localAddress: SocketAddress,
        promise: ChannelPromise
    ): ChannelFuture {
        return channel.connect(remoteAddress, localAddress, promise)
    }

    override fun disconnect(promise: ChannelPromise): ChannelFuture {
        return channel.disconnect(promise)
    }

    override fun close(promise: ChannelPromise): ChannelFuture {
        return channel.close()
    }

    override fun deregister(promise: ChannelPromise): ChannelFuture {
        return channel.deregister(promise)
    }

    override fun read(): Channel {
        return channel.read()
    }

    override fun write(msg: Any): ChannelFuture {
        return channel.write(msg)
    }

    override fun write(msg: Any, promise: ChannelPromise): ChannelFuture {
        return channel.write(msg, promise)
    }

    override fun flush(): Channel {
        return channel.flush()
    }

    override fun writeAndFlush(msg: Any, promise: ChannelPromise): ChannelFuture {
        return channel.write(msg, promise)
    }

    override fun writeAndFlush(msg: Any): ChannelFuture {
        return channel.writeAndFlush(msg)
    }

    override fun newPromise(): ChannelPromise {
        return channel.newPromise()
    }

    override fun newProgressivePromise(): ChannelProgressivePromise {
        return channel.newProgressivePromise()
    }

    override fun newSucceededFuture(): ChannelFuture {
        return channel.newSucceededFuture()
    }

    override fun newFailedFuture(cause: Throwable): ChannelFuture {
        return channel.newFailedFuture(cause)
    }

    override fun voidPromise(): ChannelPromise {
        return channel.voidPromise()
    }

    override fun <T> attr(key: AttributeKey<T>): Attribute<T> {
        return channel.attr(key)
    }

    override fun <T> hasAttr(key: AttributeKey<T>): Boolean {
        return channel.hasAttr(key)
    }

    override fun compareTo(other: Channel): Int {
        return channel.compareTo(other)
    }
}